﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ShopMS.Common;
using ShopMS.Data;
using System.Data;

namespace ShopMS.Member
{
    /// <summary>
    /// MemberManager.xaml 的交互逻辑
    /// </summary>
    public partial class MemberManager : UserControl,ShopMS.Common.IPlugin
    {
        private DataAccess access = new DataAccess();
        public MemberManager()
        {
            InitializeComponent();
        }

        public FunInfo GetFunInfo()
        {
            FunInfo info = new FunInfo();
            info.funId = "ShopMS.Member.MemberManager";
            info.funName = "会员管理";
            info.funDesc = "管理会员信息";
            info.funIcon = "fun_member";
            info.showOrder = 1;
            return info;
        }

        private void btnQuery_Click(object sender, RoutedEventArgs e)
        {
            QueryData();
        }

        private void QueryData()
        {
            string sql = "select * from member where 1=1 ";
            if (txtMemName.Text.Trim() != string.Empty)
                sql += string.Format(" and memName like '%{0}%' ", txtMemName.Text.Trim());
            if (txtMemNo.Text.Trim() != string.Empty)
                sql += string.Format(" and memName like '%{0}%' ", txtMemNo.Text.Trim());
            if (txtPhoneNo.Text.Trim() != string.Empty)
                sql += string.Format(" and memName like '%{0}%' ", txtPhoneNo.Text.Trim());
            DataTable dt = access.getDataTable(sql);
            grdData.ItemsSource = dt.DefaultView;
        }

        private void btnAddNew_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnModify_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
